<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
  <style>
    .red{
      color: red;
    }
    .green{
      color: green;
    }
  </style>
</head>
<body>
<p>需求要同时存在数字和字母才能验证通过</p>
<input type="text" onblur="inputBlur(this)" maxlength="6">
<p id="resultInfo"></p>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.0/jquery.min.js"></script>
<script>
  function inputBlur(msg) {
    // let reg = /^([\d]+[a-zA-Z]+([a-zA-Z]+|[\d])*)|[a-zA-Z]+[\d]+([a-zA-Z]+|[\d])*$/;
    let reg = /^(?=.*[0-9])(?=.*[a-zA-Z])(.{6})$/;
    let index = reg.test($(msg).val());
    console.log(index);
    if (index) {
      $('#resultInfo').text('验证成功');
      $('#resultInfo').addClass('green');
      $('#resultInfo').removeClass('red');
    } else {
      $('#resultInfo').text('验证失败');
      $('#resultInfo').addClass('red');
      $('#resultInfo').removeClass('green');
    }
  }
  let result = "hello".replace(/(?=l)/g, '#');

  console.log(result);

</script>
</body>
</html>